/* Helper Card Styles */
/* Theme tokens */
:root {
    --helper-bg: #ffffff;
    --helper-surface: #f6f8fa;
    --helper-border: #e1e4e8;
    --helper-border-strong: #c8d1dc;
    --helper-text: #24292e;
    --helper-text-muted: #586069;
    --helper-primary: #0366d6;
    --helper-primary-weak: #f1f8ff;
    --helper-success: #28a745;
    --helper-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --helper-shadow-hover: 0 8px 24px rgba(140, 149, 159, 0.2);

    /* Prototype color tokens (Solarized Light, extra contrast) */
    --proto-fn: #6f5700;
    /* deeper yellow */
    --proto-type: #4a51a3;
    /* deeper violet */
    --proto-param: #157a80;
    /* deeper cyan */
    --proto-key: #1b5fa5;
    /* deeper blue */
    --proto-op: #a11d4f;
    /* deeper magenta */
    --proto-str: #556b00;
    /* deeper green */
    --proto-num: #973e12;
    /* deeper orange */
    --proto-punc: #36454f;
    /* deeper base01 */
}

html[data-theme='dark'] {
    --helper-bg: #0d1117;
    --helper-surface: #161b22;
    --helper-border: #30363d;
    --helper-border-strong: #3d444d;
    --helper-text: #c9d1d9;
    --helper-text-muted: #8b949e;
    --helper-primary: #2f81f7;
    --helper-primary-weak: #0b1f3a;
    --helper-success: #2ea043;
    --helper-shadow: 0 1px 3px rgba(1, 4, 9, 0.4);
    --helper-shadow-hover: 0 8px 24px rgba(1, 4, 9, 0.6);

    /* Prototype color tokens (Solarized Dark) */
    --proto-fn: #b58900;
    /* yellow */
    --proto-type: #6c71c4;
    /* violet */
    --proto-param: #2aa198;
    /* cyan */
    --proto-key: #268bd2;
    /* blue */
    --proto-op: #d33682;
    /* magenta */
    --proto-str: #859900;
    /* green */
    --proto-num: #cb4b16;
    /* orange */
    --proto-punc: #93a1a1;
    /* base1 */
}

ul.helper-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

ul.helper-list>li {
    list-style: none;
    margin: 0;
}

.helper-card {
    background: var(--helper-bg);
    border: 1px solid var(--helper-border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 150ms ease, box-shadow 200ms ease, transform 200ms ease;
    box-shadow: var(--helper-shadow);
    position: relative;
    overflow: hidden;
}

.helper-card:hover {
    border-color: var(--helper-primary);
    box-shadow: var(--helper-shadow-hover);
    transform: translateY(-2px);
}

.helper-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(1200px 200px at -20% -10%, rgba(3, 102, 214, 0.06), transparent 40%),
        radial-gradient(800px 200px at 120% 110%, rgba(3, 102, 214, 0.04), transparent 40%);
    pointer-events: none;
}

.helper-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.helper-card__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.helper-card__title a {
    color: var(--helper-text);
    text-decoration: none;
}

.helper-card__title a:hover {
    color: var(--helper-primary);
}

.helper-card__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.helper-card__badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.helper-card__badge {
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.helper-card__badge--category {
    background: var(--helper-primary-weak);
    color: var(--helper-primary);
    border: 1px solid var(--helper-border-strong);
}

.helper-card__badge--subcategory {
    background: var(--helper-surface);
    color: var(--helper-text-muted);
    border: 1px solid var(--helper-border);
}

.helper-card__content {
    margin-bottom: 1rem;
}

.helper-card__markdown {
    color: var(--helper-text);
    line-height: 1.6;
}

.helper-card__markdown p {
    margin: 0 0 0.75rem 0;
}

.helper-card__markdown a {
    color: var(--helper-primary);
    text-decoration: underline;
}

.helper-card__markdown code {
    background: var(--helper-surface);
    border: 1px solid var(--helper-border);
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

.helper-card__markdown pre {
    background: var(--helper-surface);
    border: 1px solid var(--helper-border);
    border-radius: 4px;
    padding: 0.75rem;
    overflow-x: auto;
}

.helper-card__markdown pre code {
    border: none;
    background: transparent;
    padding: 0;
}

.helper-card__description {
    color: var(--helper-text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.helper-card__signature {
    margin-bottom: 1rem;
}

.helper-card__signature h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #24292e;
}

.helper-card__code {
    background: var(--helper-surface);
    border: 1px solid var(--helper-border);
    border-radius: 4px;
    padding: 0.75rem;
    margin: 0;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-x: auto;
}

.helper-card__code::-webkit-scrollbar {
    height: 8px;
}

.helper-card__code::-webkit-scrollbar-thumb {
    background: var(--helper-border-strong);
    border-radius: 4px;
}

.helper-card__examples {
    margin-bottom: 1rem;
}

.helper-card__examples h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #24292e;
}

.helper-card__example {
    margin-bottom: 0.75rem;
}

.helper-card__example h5 {
    margin: 0 0 0.25rem 0;
    font-size: 0.75rem;
    font-weight: 500;
    color: #586069;
}

.helper-card__similar {
    margin-bottom: 1rem;
}

.helper-card__similar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.helper-card__section-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.helper-card__prototype-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.helper-card__prototype-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--helper-text-muted);
    flex: 0 0 auto;
    margin-top: 0;
}

.helper-card__similar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Right-side sticky TOC */
.helper-toc {
    position: sticky;
    top: calc(var(--ifm-navbar-height) + var(--ifm-toc-padding-vertical, 1rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding-left: 1rem;
    border-left: 1px solid var(--ifm-toc-border-color, var(--ifm-color-emphasis-200));
}

.helper-toc__title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--ifm-color-emphasis-700);
}

.helper-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.helper-toc__item {
    margin: 0.25rem 0;
}

.helper-toc__link {
    font-size: 0.9rem;
    text-decoration: none;
}

.helper-card__similar-link {
    padding: 0.25rem 0.5rem;
    background: var(--helper-surface);
    border: 1px solid var(--helper-border);
    border-radius: 4px;
    color: var(--helper-primary);
    text-decoration: none;
    font-size: 0.75rem;
    transition: all 0.2s ease;
}

.helper-card__similar-link:hover {
    background: var(--helper-primary-weak);
    border-color: var(--helper-primary);
}

.helper-card__similar-prefix {
    color: var(--helper-text-muted);
}

.helper-card__footer {
    border-top: 1px solid #e1e4e8;
    padding-top: 1rem;
    text-align: center;
}

/* Prototype block (compact code block placed after similar helpers) */
.helper-card__prototype {
    margin-top: 0.25rem;
    border-top: 1px dashed var(--helper-border);
    padding-top: 0.75rem;
}

.helper-card__prototype-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.helper-card__prototype-code {
    font-size: 0.80rem;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    margin: 0;
    flex: 1 1 auto;
    width: 100%;
}

/* Token colors inside prototype code only */
.helper-card__prototype-code .token.keyword {
    color: var(--proto-key) !important;
}

.helper-card__prototype-code .token.function {
    color: var(--proto-fn) !important;
    font-weight: 600;
}

.helper-card__prototype-code .token.punctuation {
    color: var(--proto-punc) !important;
}

.helper-card__prototype-code .token.operator {
    color: var(--proto-op) !important;
}

.helper-card__prototype-code .token.constant,
.helper-card__prototype-code .token.number {
    color: var(--proto-num) !important;
}

.helper-card__prototype-code .token.parameter,
.helper-card__prototype-code .token.variable {
    color: var(--proto-param) !important;
}

.helper-card__prototype-code .token.class-name,
.helper-card__prototype-code .token.builtin,
.helper-card__prototype-code .token.type,
.helper-card__prototype-code .token.generic,
.helper-card__prototype-code .token.type-parameter,
.helper-card__prototype-code .token.template,
.helper-card__prototype-code .token.namespace {
    color: var(--proto-type) !important;
    font-weight: 600;
}

/* Force violet for all generic type parameters in prototype block */
.helper-card__prototype-code .token.type-parameter {
    color: var(--proto-type) !important;
    font-weight: 600;
}

/* Also target any spans we create for generics */
.helper-card__prototype-code span.token.type.type-parameter {
    color: var(--proto-type) !important;
    font-weight: 600;
}

/* Strings mapping */
.helper-card__prototype-code .token.string {
    color: var(--proto-str) !important;
}

.helper-card__prototype-code code {
    padding: 0.4rem;
}

/* Copy button */
.helper-card__copy {
    padding: 0.125rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    line-height: 1;
    border: 1px solid var(--helper-border);
    background: var(--helper-surface);
    color: var(--helper-text);
    cursor: pointer;
}

.helper-card__copy:hover {
    border-color: var(--helper-primary);
}

.helper-card__copy.is-copied {
    background: #2ea043;
    color: #ffffff;
    border-color: #2ea043;
}

/* Reduce Prism copy button size inside prototype code blocks */
.helper-card__prototype-code .clean-btn,
.helper-card__prototype-code .theme-code-block-copy-button {
    display: none !important;
}

.helper-card__godoc {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: var(--helper-primary);
    color: #ffffff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
}

.helper-card__source {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: rgba(168, 85, 247, 0.12);
    /* soft purple */
    color: #6d28d9;
    /* purple-700 */
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid rgba(167, 139, 250, 0.6);
}

.helper-card__source:hover {
    background: #c084fc;
    /* purple-400 - much lighter */
    color: #ffffff;
    text-decoration: none;
}

html[data-theme='dark'] .helper-card__source {
    background: rgba(168, 85, 247, 0.22);
    color: #c4b5fd;
    /* purple-300 */
    border-color: rgba(167, 139, 250, 0.75);
}

html[data-theme='dark'] .helper-card__source:hover {
    background: #c084fc;
    color: #ffffff;
}

.helper-card__godoc:hover {
    background: #0256cc;
    color: #ffffff;
    text-decoration: none;
}

.helper-card__playground {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: var(--helper-success);
    color: #ffffff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
}

.helper-card__playground:hover {
    background: #22863a;
    color: #ffffff;
    text-decoration: none;
}

/* Focus visibility */
.helper-card a:focus-visible,
.helper-card__similar-link:focus-visible,
.helper-card__source:focus-visible,
.helper-card__godoc:focus-visible,
.helper-card__playground:focus-visible {
    outline: 2px solid var(--helper-primary);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Motion reduction */
@media (prefers-reduced-motion: reduce) {

    .helper-card,
    .helper-card * {
        transition: none !important;
    }
}